package com.supply.supplymanage.controller;

import com.github.pagehelper.PageInfo;
import com.sun.org.apache.bcel.internal.generic.RETURN;
import com.supply.supplymanage.biz.ConSeleBiz;
import com.supply.supplymanage.util.ChicaUtil;
import com.supply.supplymanage.util.JsonAll;
import com.supply.supplymanage.util.OrderUtil;
import com.supply.supplymanage.util.SupUtil;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @RestController
 * @RestController注解，相当于@Controller+@ResponseBody两个注解的结合，
 * 返回json数据不需要在方法前面加@ResponseBody注解了，但使用@RestController这个注解，
 * 就不能返回jsp,html页面，视图解析器无法解析jsp,html页面
 *
 */
@RestController
@RequestMapping("/consele")
public class ConSeleController {
    @Resource
    ConSeleBiz conSeleBiz;

    //得到所有基本信息
    @RequestMapping("seleAll")
    public @ResponseBody Map seleAll(){
        Map map = conSeleBiz.selConAll();
        return map;
    }
    //根据款号查款式
    @RequestMapping("seledesign/{haoid}")
    public @ResponseBody List<Map> seledes(@PathVariable("haoid") int haoid){
        List<Map> seledesign = conSeleBiz.seledesign(haoid);
        System.out.println(seledesign);
        return seledesign;
    }
    //查询所有尺码
    @RequestMapping("seleAllsize")
    public @ResponseBody List<Map> seleAllsize(){
        List<Map> maps = conSeleBiz.seleAllsize();
        System.out.println(maps);
        return maps;
    }
    //根据id查尺码 暂时抛弃
    @RequestMapping("seleSize/{chval}")
    public @ResponseBody  List<Map> seleSize(@PathVariable("chval") int[] chval){
        List<Map> maps = conSeleBiz.seleSize(chval);
        System.out.println(maps);
        return maps;
    }
    //查询所有未停用颜色
    @RequestMapping("seleseleTinct")
    public @ResponseBody PageInfo seleTinct(@RequestParam("PageNum") int pageNum
            ,@RequestParam("typecolor") String typecolor,@RequestParam("colorname") String colorname){
        if(colorname!=null){
            System.out.println(colorname);
        }
        PageInfo pageInfo = conSeleBiz.seleTinct(pageNum,typecolor,colorname);
        System.out.println(pageInfo);
        return pageInfo;
    }
    //查询颜色类别
    @RequestMapping("seleTincttype")
    public @ResponseBody List<Map> seleTincttype(){

        return conSeleBiz.seleTincttype();
    }
    //根据款式查出所需服装部位
    @RequestMapping("selecloth/{designid}")
    public @ResponseBody List<Map> selecloth(@PathVariable("designid") int designid){
        return conSeleBiz.selecloth(designid);
    }
    //查询所有物料信息
    @RequestMapping("selesuppliesdeta")
    public @ResponseBody PageInfo selesuppliesdeta(
            @RequestParam("PageNum") int PageNum,@RequestParam("bomgys") String bomgys,
              @RequestParam("bomwlname") String bomwlname,@RequestParam("bomcolor") String bomcolor){
        System.out.println(1);
        PageInfo selesuppliesdeta = conSeleBiz.selesuppliesdeta(PageNum,bomgys,bomwlname,bomcolor);
        System.out.println(selesuppliesdeta);
        return selesuppliesdeta;
    }
    //读取excel
    @RequestMapping("seleExcel")
    public List<Map> selExcel(HttpRequest s){

        return null;
    }
    //提交样板订单   多个数组+多个实体
    @RequestMapping("subsup")
    public @ResponseBody String insertTemp(@RequestBody JsonAll jsonAll){

        conSeleBiz.insertTemp(jsonAll);
        return  "1";
    }



}
